//
//  CityChooserCellModel.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/12/20.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "CityChooserCellModel.h"

@interface CityChooserCellModel ()

@property (nonatomic, readwrite, assign) BOOL isChoose;
@property (nonatomic, readwrite, copy) NSString* cityName;
@property (nonatomic, readwrite, strong) UIColor* bColor;

@end

@implementation CityChooserCellModel

- (instancetype)initWithData:(id)data cellHeight:(CGFloat)cellHeight
{
    self = [super init];
    if (self)
    {
        _data = data;
        
        /// cellHeight+2（2容错）
        _cellHeight = MHUIScaleValue(cellHeight)+2;
        
        @weakify(self);
        ProvinceListData* pListData = data;
        
        [[RACObserve(self, isSub) takeUntil:[self rac_willDeallocSignal]] subscribeNext:^(id x)
        {
            @strongify(self);
            
            BOOL isSub = [x boolValue];
            
            self.bColor = isSub ? UIColorHex(#f0f0f0) : UIColorHex(#ffffff);
        }];
        
        [[RACObserve(pListData, isChoose) takeUntil:[self rac_willDeallocSignal]] subscribeNext:^(id x)
        {
            @strongify(self);
            
            self.isChoose = [x boolValue];
        }];
        self.cityName = pListData.name;
        self.bColor = pListData.backgroundColor;
        self.isOn = NO;
    }
    
    return self;
}

@end
